package m.jclecai.com.adapter.holder;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import m.jclecai.com.R;

import butterknife.BindView;
import m.jclecai.com.bean.GroupBuyDetailBean;
import m.jclecai.com.bean.Matchorder;

import java.util.List;

/**
 * Created by ZD on 2017/5/16.
 */

public class GroupBuyInfoHolder extends ViewHolder {

    @BindView(R.id.list_item_parent_title)
    public TextView list_item_parent_title;
    //    @BindView(R.id.tv_tag)
//    public TextView tv_tag;
    @BindView(R.id.list_item_parent_icon)
    public ImageView list_item_parent_icon;
    @BindView(R.id.iv_drive)
    public View iv_drive;
    @BindView(R.id.tv_follow_detail_project_times)
    TextView tv_follow_detail_project_times;
    @BindView(R.id.tv_follow_detail_project_mode)
    TextView tv_follow_detail_project_mode;
    @BindView(R.id.tv_follow_detail_project_beishu)
    TextView tv_follow_detail_project_beishu;
    private GroupBuyDetailBean groupBuyDetailBean;

    public GroupBuyInfoHolder(Context context, @LayoutRes int resource) {
        super(context, resource);
    }

    public void init(int groupPosition, String teambuy_isshow,
                     String fllowPeople, boolean isExpanded, String term) {
        if (groupPosition == 0) {
            list_item_parent_title.setText("投注信息");
            tv_follow_detail_project_times.setText(groupBuyDetailBean.getMatchorder().size()+"场");//场数
            tv_follow_detail_project_mode.setText(groupBuyDetailBean.getMethodname());
            tv_follow_detail_project_beishu.setText(groupBuyDetailBean.getMultiple() + "倍");

//            tv_tag.setText(teambuy_isshow);
//            tv_tag.setTextColor(ContextCompat.getColor(getContext(),R.color.login_txt));
        } else {
            if (!TextUtils.isEmpty(term)) {
                String str[] = term.split(",");
                list_item_parent_title.setText(str[0]);
//                tv_tag.setText(str[1]);
            } else {
                list_item_parent_title.setText("跟单人数");
//                tv_tag.setText(fllowPeople);
            }
//            tv_tag.setTextColor(ContextCompat.getColor(getContext(),R.color.a));
        }
        iv_drive.setVisibility(View.VISIBLE);
        if (!isExpanded) {
            list_item_parent_icon.setImageResource(R.drawable.cz);
        } else {
            list_item_parent_icon.setImageResource(R.drawable.d0);
        }
    }

    public void setData(GroupBuyDetailBean groupBuyDetailBean) {
        this.groupBuyDetailBean = groupBuyDetailBean;
    }
}
